
function Get-NavFiler {
	<#
	.SYNOPSIS
		Retrieve information about all vfilers.
	.DESCRIPTION
		Retrieve information about all vfilers. An optional vfiler parameter 
		lets you retrive information about a single vfiler.
	.PARAMETER Name
		Name of the vfiler whose information you want to retrieve. If this 
		parameter is not provided and you are connected to a pfiler then, 
		information about all vfilers will be retrieved. If this parameter 
		is not provided and if you are connected to a vfiler then 
		information about that vfiler will be retrieved. 
	.PARAMETER Server
		NaServer to query
	.EXAMPLE
		Get-NavFiler
	.Link
	.OUTPUT
		Netapp.SDK.NavFiler[]
	#> 
	[CmdletBinding(SupportsShouldProcess=$false,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")] 
	param(
	[Parameter(ValueFromPipelineByPropertyName=$TRUE)]
	[string]
	$Name,

	[Parameter(HelpMessage="NaServer to query")]
	[NetApp.SDK.NaServer]
	$Server = (Get-NaServer)
	)
	Process {
		$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-list-info")
		if ($Name) {
			$request.AddNewChild("vfiler",$Name)
		}
		try {
			$result = ([xml]$server.InvokeElem($request)).results
		}
		catch [NetApp.Manage.NaApiFailedException]{
			Write-Warning $_.Exception.GetBaseException().message
			$result = $null
			continue;
		}
		if ($?) {
			$result.vfilers."vfiler-info" | % {
				$Protocols = (Get-NavFilerProtocols -Name $_.name -Server $server)
				New-Object Netapp.SDK.NavFiler -ArgumentList @(
				$_.name,
				(Get-NavFilerStatus -Name $_.Name -Server $server),
				[Array]($_.vfnets."vfnet-info" | % {
					New-Object Netapp.SDK.NavFNet -ArgumentList @(
					$_."interface",
					[System.Net.IPAddress]$_."ipaddress",
					$_."netmask"
					)
				}),
				[Array]($_.vfstores."vfstore-info" | % {
					New-Object Netapp.SDK.NavFStorage -ArgumentList @(
					(ConvertFrom-NaBool $_."is-etc"),
					$_."path",
					$_."status"

					)
				}),
				$_.ipspace,
				$_.uuid,
				$Protocols.NFS,
				$Protocols.CIFS,
				$Protocols.RSH,
				$Protocols.iSCSI,
				[Array]($_."dns-info" | Select-Object @{
					n="DNSDomainName";
					e={$_."dns-domain-name"}
				}, @{
					Name="DNSServers";
					Expression={[string[]]$_."dns-servers".Server}
				}
				),
				[Array]($_."nis-info" | Select-Object @{
					n="NISDomainName";
					e={$_."nis-domain-name"}
				}, @{
					Name="NISServers";
					Expression={[string[]]$_."nis-servers".Server}
				}
				),
				$_."admin-host"
				)
			}
		}
	}
}
function Set-NavFiler {
	<#
	.SYNOPSIS
		Set services for a vfiler that has been already created. 
	.DESCRIPTION
		Set services for a vfiler that has been already created. 
	.PARAMETER Name
		Name of the vFiler. 
	.PARAMETER AdminhostIP
		IP address of administrative host. IP address is either IPv4 address or IPv6 address.
	.PARAMETER AdminhostName
		name of administrative host, optional
	.PARAMETER DNSDomain
		DNS domain name
	.PARAMETER DNSServers
		DNS server IP address. IP address is either IPv4 address or IPv6 address. 
	.PARAMETER NISDomain
		NIS domain name 
	.PARAMETER NISServers
		NIS server IP address, or "*". IP address is either IPv4 address or IPv6 address. 
	.PARAMETER IpBindingIPaddress
		IP address to bind binding. IP address is either IPv4 address or IPv6 address.
	.PARAMETER IpBindingNetmask
		Netmask or Prefix length of IP address binding  
	.PARAMETER IpBindingInterface
		Name of interface to bind IP address to. 
	.PARAMETER Password
		root password for the vfiler 
	.PARAMETER Server
		NaServer to query
	.EXAMPLE
		Set-NavFiler Netapp2 -DNSDomain getadmin.local -DNSServers 192.168.1.1,192.168.1.2
		
		Set the DNS Domainname and Search servers for the getadmin.local dns domain.
	.EXAMPLE
		Set-NavFiler Netapp2 -IpBindingIPaddress 192.168.1.133 `
			-IpBindingNetmask 255.255.255.0 `
			-IpBindingInterface ns0
		
		Bind the 192.168.1.0/24 network to the ns0 interface
	.EXAMPLE
		New-NavFiler -Name netapp2 -IPAddress 192.168.1.35 -Path /vol/vol1 |
			Set-NavFiler -DNSDomain getadmin.local -DNSServers 192.168.1.1,192.168.1.2 |
			Set-NavFiler -NISDomain getadmin -NISServers 192.168.1.10,192.168.1.11 |
			Set-NavFiler -IpBindingIPaddress 192.168.1.35 `
				-IpBindingNetmask 255.255.255.0 `
				-IpBindingInterface ns0 |
			Set-NavFiler -Password "Pa22w0rd" |
			Remove-NavFilerProtocols -RSH
		
		Complete vFiler one line of powershell

	.Link
	.OUTPUT
		Netapp.SDK.NavFiler[]
	#> 
	[CmdletBinding(SupportsShouldProcess=$true,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")] 
	param(
	[Parameter(Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE,ParameterSetName="AdminHost")]
	[Parameter(Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE,ParameterSetName="dns")]
	[Parameter(Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE,ParameterSetName="nis")]
	[Parameter(Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE,ParameterSetName="ip")]
	[Parameter(Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE,ParameterSetName="password")]
	[string]
	$Name,

	[Parameter(Mandatory=$TRUE,ValueFromPipelineByPropertyName=$TRUE,ParameterSetName="AdminHost")]
	[string]
	$AdminhostIP,

	[Parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$TRUE,ParameterSetName="AdminHost")]
	[string]
	$AdminhostName,
	
	[Parameter(Mandatory=$TRUE,ValueFromPipelineByPropertyName=$TRUE,ParameterSetName="dns")]
	[string]
	$DNSDomain,
	
	[Parameter(Mandatory=$TRUE,ValueFromPipelineByPropertyName=$TRUE,ParameterSetName="dns")]
	[string[]]
	$DNSServers,
	
	[Parameter(Mandatory=$TRUE,ValueFromPipelineByPropertyName=$TRUE,ParameterSetName="nis")]
	[string]
	$NISDomain,
	
	[Parameter(Mandatory=$TRUE,ValueFromPipelineByPropertyName=$TRUE,ParameterSetName="nis")]
	[string[]]
	$NISServers,
	
	[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE,ParameterSetName="ip")]
	[string]
	$IpBindingIPaddress,
	
	[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE,ParameterSetName="ip")]
	[string]
	$IpBindingNetmask,
	
	[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE,ParameterSetName="ip")]
	[string]
	$IpBindingInterface,
	
	[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE,ParameterSetName="password")]
	[string]
	$Password,

	[Parameter(HelpMessage="NaServer to query")]
	[NetApp.SDK.NaServer]
	$Server = (Get-NaServer)
	)
	Process {
		$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-setup")
		$request.AddNewChild("vfiler",$Name)
		switch ($pscmdlet.ParameterSetName)
		{
			"adminhost" {
				$adminhost = New-Object Netapp.Manage.NaElement -ArgumentList @("adminhost")
				$adminhost.AddNewChild("ipaddress", $AdminhostIP)
				$adminhost.AddNewChild("name",$AdminhostName)
				$request.AddChildElement($adminhost)
				$msg = "Setting $($AdminhostName):$($AdminhostIP) as the administrative host"
			}
			"dns"		{
				$msg = "Setting DNS"
				if ($DNSDomain) {
					$request.AddNewChild("dnsdomain",$DNSDomain)
					$msg = "{0} Domain:{1}" -f $msg, $DNSDomain
				}
				if ($DNSServers) {
					$dnsips = New-Object Netapp.Manage.NaElement -ArgumentList @("dnsservers")
					$DNSServers | %{
						$dnsserverInfo = New-Object Netapp.Manage.NaElement -ArgumentList @("dnsserver-info")
						$dnsserverInfo.AddNewChild("ipaddress",$_)
						$dnsips.AddChildElement($dnsserverInfo)
					}
					$request.AddChildElement($dnsips)
					$msg = "{0} Servers:{1}" -f $msg, ($DNSServers -join ',')
				}
			}
			"nis"		{
				$msg = "Setting NIS"
				if ($NISDomain) {
					$request.AddNewChild("nisdomain",$NISDomain)
					$msg = "{0} Domain:{1}" -f $msg, $DNSDomain
				}
				if ($NISServers) {
					$nisips = New-Object Netapp.Manage.NaElement -ArgumentList @("nisservers")
					$NISServers | %{
						$nisserverInfo = New-Object Netapp.Manage.NaElement -ArgumentList @("nisserver-info")
						$nisserverInfo.AddNewChild("ipaddress",$_)
						$nisips.AddChildElement($nisserverInfo)
					}
					$request.AddChildElement($nisips)
					$msg = "{0} Servers:{1}" -f $msg, ($DNSServers -join ',')
				}
			}
			"ip"		{
				$ipbindings = New-Object Netapp.Manage.NaElement -ArgumentList @("ipbindings")
				
				$ipbindingInfo = New-Object Netapp.Manage.NaElement -ArgumentList @("ipbinding-info")
				$ipbindingInfo.AddNewChild("interface",$IpBindingInterface)
				$ipbindingInfo.AddNewChild("ipaddress",$IpBindingIPaddress)
				$ipbindingInfo.AddNewChild("netmask",$IpBindingNetmask)
				$ipbindings.AddChildElement($ipbindingInfo)

				$request.AddChildElement($ipbindings)
				$msg = "Binding {0} {1} to {2}" -f $IpBindingIPaddress, $IpBindingNetmask, $IpBindingInterface
			}
			"password"	{
				$request.AddNewChild("password",$Password)
				$msg = "Setting root password"
			}
		}
		$msg = "{0} on vFiler:{1}" -f $msg, $Name
		
		if ($pscmdlet.ShouldProcess($Server.Server,$msg)){
			try {
				$result = ([xml]$server.InvokeElem($request)).results
			}
			catch [NetApp.Manage.NaApiFailedException]{
				Write-Warning $_.Exception.GetBaseException().message
				$result = $null
				continue;
			}
			if ($?) {
				return Get-NavFiler -Name $Name -Server $Server
			}
		}
	}
}
function New-NavFiler {
	<#
	.SYNOPSIS
		Create a new vFiler 
	.DESCRIPTION
		Create a new vFiler 
	.PARAMETER Name
		Name of the vFiler. 
	.PARAMETER IPAddress
		Ipaddress, in dotted-decimal format (for example, "192.168.11.12").
	.PARAMETER Path
		Storage-path, in the form "/vol/<volume>/..."
	.PARAMETER IpSpace
		Name of the vfiler's ipspace 
	.PARAMETER Server
		NaServer to query
	.EXAMPLE
		New-NavFiler -Name Netapp3 -IPAddress 192.168.1.35 -Path /vol/vol3
	.Link
	.OUTPUT
		Netapp.SDK.NavFiler[]
	#> 
	[CmdletBinding(SupportsShouldProcess=$true,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")] 
	param(
	[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE)]
	[string]
	$Name,

	[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE)]
	[string[]]
	$IPAddress,

	[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE)]
	[string[]]
	$Path,

	[Parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$TRUE)]
	[string]
	$IpSpace,

	[Parameter(HelpMessage="NaServer to query")]
	[NetApp.SDK.NaServer]
	$Server = (Get-NaServer)
	)
	Process {
		$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-create")
		$request.AddNewChild("vfiler",$Name)
		
		$IP = New-Object Netapp.Manage.NaElement -ArgumentList @("ip-addresses")
		$IPAddress | % {
			$IP.AddNewChild("ip-address",$_)
		}
		$request.AddChildElement($IP)
		
		$P = New-Object Netapp.Manage.NaElement -ArgumentList @("storage-units")
		$Path | % {
			$P.AddNewChild("storage-unit",$_)
		}
		$request.AddChildElement($P)
		
		if ($IpSpace) {
			$request.AddNewChild("ipspace",$IpSpace)
		}
		if ($pscmdlet.ShouldProcess($Server.Server,
				"Creating vFiler:$($Name) using Path(s):$($Path -join ',') IP(s):$($IPAddress -join ',')")){
			try {
				$result = ([xml]$server.InvokeElem($request)).results
			}
			catch [NetApp.Manage.NaApiFailedException]{
				Write-Warning $_.Exception.GetBaseException().message
				$result = $null
				continue;
			}
			if ($?) {
				return Get-NavFiler -Name $Name -Server $Server
			}
		}
	}
}
function Remove-NavFiler {
	<#
	.SYNOPSIS
		Delete a vFiler 
	.DESCRIPTION
		Delete a vFiler 
	.PARAMETER Name
		Name of the vFiler. 
	.PARAMETER Force
		Surpress any errors and removes the vfiler.
	.PARAMETER Server
		NaServer to query
	.EXAMPLE
		Remove-NavFiler -Name Netapp3 
	.Link
	.OUTPUT
		Netapp.SDK.NavFiler[]
	#> 
	[CmdletBinding(SupportsShouldProcess=$true,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")] 
	param(
		[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE)]
		[string]
		$Name,
		
		[Parameter(Mandatory=$False)]
		[switch]
		$Force,
	
		[Parameter(HelpMessage="NaServer to query")]
		[NetApp.SDK.NaServer]
		$Server = (Get-NaServer)
	)
	Process {
		$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-destroy")
		$request.AddNewChild("vfiler",$Name)
		
		if ($pscmdlet.ShouldProcess($Server.Server, "Destroying vFiler:($Name)")){
			try {
				$server.InvokeElem($request)|out-null
			}
			catch [NetApp.Manage.NaApiFailedException]{
				if ($_.Exception.GetBaseException().message -match "running" -and $Force) {
					Stop-NavFiler -Name $Name -Server $Server | Remove-NavFiler -Server $Server
				} else {
					Write-Warning $_.Exception.GetBaseException().message
					continue;
				}
			}
		}
	}
}

function Get-NavFilerProtocols {
	<#
	.SYNOPSIS
		Get the protocols allowed for a vfiler
	.DESCRIPTION
		Get the protocols allowed for a vfiler
	.PARAMETER vFiler
		Name of the vfiler
	.PARAMETER Server
		NaServer to query
	.EXAMPLE
		Get-NavFilerProtocols -Name vFiler0
	.Link
	.OUTPUT
		PSObject[]
	#> 
	[CmdletBinding(SupportsShouldProcess=$false,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")] 
	param(
	[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE)]
	[string]
	$Name,

	[Parameter(HelpMessage="NaServer to query")]
	[NetApp.SDK.NaServer]
	$Server = (Get-NaServer)
	)
	Process {
		$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-get-allowed-protocols")
		$request.AddNewChild("vfiler",$Name)
		try {
			$result = ([xml]$server.InvokeElem($request)).results
		}
		catch [NetApp.Manage.NaApiFailedException]{
			Write-Warning $_.Exception.GetBaseException().message
			$result = $null
			continue;
		}
		if ($?) {
			$obj = New-Object PSObject -Property @{
				"NFS" = $False
				"CIFS" = $False
				"RSH" = $False
				"ISCSI" = $False
			}
			$result."allowed-protocols"."protocol-info" | % {
				switch ($_.protocol)
				{
					"NFS" {$obj.NFS = $True}
					"CIFS" {$obj.CIFS = $True}
					"RSH" {$obj.RSH = $True}
					"ISCSI" {$obj.ISCSI = $True}
				}
			}
			return $obj
		}
	}
}
function Add-NavFilerProtocols {
	<#
	.SYNOPSIS
		Allow a protocol on a specified vfiler 
	.DESCRIPTION
		Allow a protocol on a specified vfiler 
	.PARAMETER Name
		Name of the vfiler. 
	.PARAMETER NFS
		Add the NFS protocol.
	.PARAMETER CIFS
		Add the CIFS protocol.
	.PARAMETER RSH
		Add the RSH protocol.
	.PARAMETER Server
		NaServer to query
	.EXAMPLE
		Get-NavFiler vFiler0 | Add-NavFilerProtocols -CIFS -NFS
	.Link
	.OUTPUT
		Netapp.SDK.NavFiler[]
	#> 
	[CmdletBinding(SupportsShouldProcess=$true,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")] 
	param(
	[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE)]
	[string]
	$Name,

	[Parameter(Mandatory=$false)]
	[switch]
	$CIFS,

	[Parameter(Mandatory=$false)]
	[switch]
	$NFS,

	[Parameter(Mandatory=$false)]
	[switch]
	$RSH,

	[Parameter(HelpMessage="NaServer to query")]
	[NetApp.SDK.NaServer]
	$Server = (Get-NaServer)
	)
	Process {
		$requests = @()
		$msg = @()
		switch ($Name) {
			{					$CIFS} {
				$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-allow-protocol")
				$request.AddNewChild("vfiler",$Name)
				$request.AddNewChild("protocol","cifs")
				$requests += $request
				$msg += "CIFS"
			}
			{					$NFS} {
				$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-allow-protocol")
				$request.AddNewChild("vfiler",$Name)
				$request.AddNewChild("protocol","nfs")
				$requests += $request
				$msg += "NFS"
			}
			{					$RSH} {
				$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-allow-protocol")
				$request.AddNewChild("vfiler",$Name)
				$request.AddNewChild("protocol","rsh")
				$requests += $request
				$msg += "RSH"
			}
		}

		if ($pscmdlet.ShouldProcess($Server.Server,"Adding $($msg -join ", ") to the allowed protocols on vFiler:$($Name)")){
			foreach ($request in $requests) {
				try {
					$result = ([xml]$server.InvokeElem($request)).results
				}
				catch [NetApp.Manage.NaApiFailedException]{
					Write-Warning $_.Exception.GetBaseException().message
					$result = $null
					continue;
				}
			}
			if ($?) {
				return Get-NavFiler -Name $Name -Server $Server
			}
		}
	}
}
function Remove-NavFilerProtocols {
	<#
	.SYNOPSIS
		Disallow a protocol on a specified vfiler 
	.DESCRIPTION
		Disallow a protocol on a specified vfiler 
	.PARAMETER Name
		Name of the vfiler. 
	.PARAMETER NFS
		Remove the NFS protocol.
	.PARAMETER CIFS
		Remove the CIFS protocol.
	.PARAMETER RSH
		Remove the RSH protocol.
	.PARAMETER Server
		NaServer to query
	.EXAMPLE
		Get-NavFiler vFiler0 | Remove-NavFilerProtocols -CIFS -RSH
	.Link
	.OUTPUT
		Netapp.SDK.NavFiler[]
	#> 
	[CmdletBinding(SupportsShouldProcess=$true,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")] 
	param(
	[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE)]
	[string]
	$Name,

	[Parameter(Mandatory=$false)]
	[switch]
	$CIFS,

	[Parameter(Mandatory=$false)]
	[switch]
	$NFS,

	[Parameter(Mandatory=$false)]
	[switch]
	$RSH,

	[Parameter(HelpMessage="NaServer to query")]
	[NetApp.SDK.NaServer]
	$Server = (Get-NaServer)
	)
	Process {
		$requests = @()
		$msg = @()
		switch ($Name) {
			{$CIFS} {
				$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-disallow-protocol")
				$request.AddNewChild("vfiler",$Name)
				$request.AddNewChild("protocol","cifs")
				$requests += $request
				$msg += "CIFS"
			}
			{$NFS} {
				$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-disallow-protocol")
				$request.AddNewChild("vfiler",$Name)
				$request.AddNewChild("protocol","nfs")
				$requests += $request
				$msg += "NFS"
			}
			{$RSH} {
				$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-disallow-protocol")
				$request.AddNewChild("vfiler",$Name)
				$request.AddNewChild("protocol","rsh")
				$requests += $request
				$msg += "RSH"
			}
		}

		if ($pscmdlet.ShouldProcess($Server.Server,"removing $($msg -join ", ") from the allowed protocols on vFiler:($Name)")){
			foreach ($request in $requests) {
				try {
					$result = ([xml]$server.InvokeElem($request)).results
				}
				catch [NetApp.Manage.NaApiFailedException]{
					Write-Warning $_.Exception.GetBaseException().message
					$result = $null
					continue;
				}
			}
			if ($?) {
				return Get-NavFiler -Name $Name -Server $Server
			}
		}
	}
}

function Start-NavFiler {
	<#
	.SYNOPSIS
		Start a stopped vfiler. This operation is synchronous. 
	.DESCRIPTION
		Start a stopped vfiler. This operation is synchronous. 
	.PARAMETER Name
		Name of the vfiler. 
	.PARAMETER Server
		NaServer to query
	.EXAMPLE
		Get-NavFiler vFiler0 | Start-NavFiler
	.Link
	.OUTPUT
		Netapp.SDK.NavFiler[]
	#> 
	[CmdletBinding(SupportsShouldProcess=$true,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")] 
	param(
		[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE)]
		[string]
		$Name,
	
		[Parameter(HelpMessage="NaServer to query")]
		[NetApp.SDK.NaServer]
		$Server = (Get-NaServer)
	)
	Process {
		$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-start")
		$request.AddNewChild("vfiler",$Name)
		if ($pscmdlet.ShouldProcess($Server.Server,"Starting vFiler:$($Name)")){
			try {
				$result = ([xml]$server.InvokeElem($request)).results
			}
			catch [NetApp.Manage.NaApiFailedException]{
				Write-Warning $_.Exception.GetBaseException().message
				$result = $null
				continue;
			}
			if ($?) {
				return Get-NavFiler -Name $Name -Server $Server
			}
		}
	}
}
function Stop-NavFiler {
	<#
	.SYNOPSIS
		Stop a started vfiler.
	.DESCRIPTION
		Stop a started vfiler.
	.PARAMETER Name
		Name of the vfiler. 
	.PARAMETER Server
		NaServer to query
	.EXAMPLE
		Get-NavFiler vFiler0 | Stop-NavFiler
	.Link
	.OUTPUT
		Netapp.SDK.NavFiler[]
	#> 
	[CmdletBinding(SupportsShouldProcess=$true,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")] 
	param(
		[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE)]
		[string]
		$Name,
	
		[Parameter(HelpMessage="NaServer to query")]
		[NetApp.SDK.NaServer]
		$Server = (Get-NaServer)
	)
	Process {
		$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-stop")
		$request.AddNewChild("vfiler",$Name)
		if ($pscmdlet.ShouldProcess($Server.Server,"Stopping vFiler:$($Name)")){
			try {
				$result = ([xml]$server.InvokeElem($request)).results
			}
			catch [NetApp.Manage.NaApiFailedException]{
				Write-Warning $_.Exception.GetBaseException().message
				$result = $null
				continue;
			}
			if ($?) {
				return Get-NavFiler -Name $Name -Server $Server
			}
		}
	}
}

function Add-NavFilerIPAddress {
	<#
	.SYNOPSIS
		Add an ipaddress to a vfiler 
	.DESCRIPTION
		Add an ipaddress to a vfiler 
	.PARAMETER Name
		Name of the vfiler. 
	.PARAMETER IPAddress
		Ipaddress to be added, in dotted-decimal format (for example, "192.168.11.12").
	.PARAMETER Server
		NaServer to query
	.EXAMPLE
		Get-NavFiler vFiler0 | Add-NavFilerIPAddress -IPAddress 192.168.1.26
	.Link
	.OUTPUT
		Netapp.SDK.NavFiler[]
	#> 
	[CmdletBinding(SupportsShouldProcess=$true,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")] 
	param(
	[Parameter(Mandatory=$true,position=0,ValueFromPipelineByPropertyName=$TRUE)]
	[string]
	$IPAddress,

	[Parameter(Mandatory=$true,position=1,ValueFromPipelineByPropertyName=$TRUE)]
	[string]
	$Name,

	[Parameter(HelpMessage="NaServer to query")]
	[NetApp.SDK.NaServer]
	$Server = (Get-NaServer)
	)
	Process {
		$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-add-ipaddress")
		$request.AddNewChild("vfiler",$Name)
		$request.AddNewChild("ipaddress",$IPAddress)
		if ($pscmdlet.ShouldProcess($Server.Server,"Adding IP:$($IPAddress) to vFiler:($Name)")){
			try {
				$result = ([xml]$server.InvokeElem($request)).results
			}
			catch [NetApp.Manage.NaApiFailedException]{
				Write-Warning $_.Exception.GetBaseException().message
				$result = $null
				continue;
			}
			if ($?) {
				return Get-NavFiler -Name $Name -Server $Server
			}
		}
	}
}
function Remove-NavFilerIPAddress {
	<#
	.SYNOPSIS
		Remove an ipaddress from a vfiler 
	.DESCRIPTION
		Remove an ipaddress from a vfiler
	.PARAMETER Name
		Name of the vfiler. 
	.PARAMETER IPAddress
		Ipaddress to be removed, in dotted-decimal format (for example, "192.168.11.12").
	.PARAMETER Server
		NaServer to query
	.EXAMPLE
		Get-NavFiler vFiler0 | Remove-NavFilerIPAddress -IPAddress 192.168.1.26
	.Link
	.OUTPUT
		Netapp.SDK.NavFiler[]
	#> 
	[CmdletBinding(SupportsShouldProcess=$true,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")] 
	param(
	[Parameter(Mandatory=$true,position=0,ValueFromPipelineByPropertyName=$TRUE)]
	[string]
	$IPAddress,

	[Parameter(Mandatory=$true,position=1,ValueFromPipelineByPropertyName=$TRUE)]
	[string]
	$Name,

	[Parameter(HelpMessage="NaServer to query")]
	[NetApp.SDK.NaServer]
	$Server = (Get-NaServer)
	)
	Process {
		$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-remove-ipaddress")
		$request.AddNewChild("vfiler",$Name)
		$request.AddNewChild("ipaddress",$IPAddress)
		if ($pscmdlet.ShouldProcess($Server.Server,"removing IP:$($IPAddress) from vFiler:$($Name)")){
			try {
				$result = ([xml]$server.InvokeElem($request)).results
			}
			catch [NetApp.Manage.NaApiFailedException]{
				Write-Warning $_.Exception.GetBaseException().message
				$result = $null
				continue;
			}
			if ($?) {
				return Get-NavFiler -Name $Name -Server $Server
			}
		}
	}
}
function Add-NavFilerStorage {
	<#
	.SYNOPSIS
		Add a storage unit to a vfiler 
	.DESCRIPTION
		Add a storage unit to a vfiler 
	.PARAMETER Name
		Name of the vfiler. 
	.PARAMETER Path
		Storage-path to be added, in the form "/vol/<volume>/..."
	.PARAMETER Server
		NaServer to query
	.EXAMPLE
		Get-NavFiler vFiler0 | Add-NavFilerStorage -Path /vol/vol3
	.EXAMPLE
		Get-NaVol vol2 | Add-NavFilerStorage -Name vFiler0
	.Link
	.OUTPUT
		Netapp.SDK.NavFiler[]
	#> 
	[CmdletBinding(SupportsShouldProcess=$true,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")] 
	param(
	[Parameter(Mandatory=$true,position=0,ValueFromPipelineByPropertyName=$TRUE)]
	[string]
	$Path,

	[Parameter(Mandatory=$true,position=1,ValueFromPipelineByPropertyName=$TRUE)]
	[string]
	$Name,

	[Parameter(HelpMessage="NaServer to query")]
	[NetApp.SDK.NaServer]
	$Server = (Get-NaServer)
	)
	Process {
		$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-add-storage")
		$request.AddNewChild("vfiler",$Name)
		$request.AddNewChild("storage-path",$Path)
		if ($pscmdlet.ShouldProcess($Server.Server,"Adding Path:$($Path) to vFiler:$($Name)")){
			try {
				$result = ([xml]$server.InvokeElem($request)).results
			}
			catch [NetApp.Manage.NaApiFailedException]{
				Write-Warning $_.Exception.GetBaseException().message
				$result = $null
				continue;
			}
			if ($?) {
				return Get-NavFiler -Name $Name -Server $Server
			}
		}
	}
}
function Remove-NavFilerStorage {
	<#
	.SYNOPSIS
		Removes a storage unit from a vfiler 
	.DESCRIPTION
		Removes a storage unit from a vfiler 
	.PARAMETER Name
		Name of the vfiler. 
	.PARAMETER Path
		Storage-path to be removed, in the form "/vol/<volume>/..."
	.PARAMETER Server
		NaServer to query
	.EXAMPLE
		Get-NavFiler vFiler0 | Remove-NavFilerStorage -Path /vol/vol3
	.EXAMPLE
		Get-NaVol vol2 | Remove-NavFilerStorage -Name vFiler0
	.Link
	.OUTPUT
		Netapp.SDK.NavFiler[]
	#> 
	[CmdletBinding(SupportsShouldProcess=$true,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")] 
	param(
	[Parameter(Mandatory=$true,position=0,ValueFromPipelineByPropertyName=$TRUE)]
	[string]
	$Path,

	[Parameter(Mandatory=$true,position=1,ValueFromPipelineByPropertyName=$TRUE)]
	[string]
	$Name,

	[Parameter(HelpMessage="NaServer to query")]
	[NetApp.SDK.NaServer]
	$Server = (Get-NaServer)
	)
	Process {
		$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-remove-storage")
		$request.AddNewChild("vfiler",$Name)
		$request.AddNewChild("storage-path",$Path)
		if ($pscmdlet.ShouldProcess($Server.Server,"removing Path:$($Path) from vFiler:$($Name)")){
			try {
				$result = ([xml]$server.InvokeElem($request)).results
			}
			catch [NetApp.Manage.NaApiFailedException]{
				Write-Warning $_.Exception.GetBaseException().message
				$result = $null
				continue;
			}
			if ($?) {
				return Get-NavFiler -Name $Name -Server $Server
			}
		}
	}
}

function Get-NavFilerStatus {
	<#
	.SYNOPSIS
		Get the status of a vfiler 
	.DESCRIPTION
		Get the status of a vfiler 
	.PARAMETER vFiler
		Name of the vfiler
	.PARAMETER Server
		NaServer to query
	.EXAMPLE
		Get-NavFilerStatus -Name vFiler0
	.Link
	.OUTPUT
		string
	#> 
	[CmdletBinding(SupportsShouldProcess=$false,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")] 
	param(
	[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$TRUE)]
	[string]
	$Name,

	[Parameter(HelpMessage="NaServer to query")]
	[NetApp.SDK.NaServer]
	$Server = (Get-NaServer)
	)
	Process {
		$request = New-Object Netapp.Manage.NaElement -ArgumentList @("vfiler-get-status")
		$request.AddNewChild("vfiler",$Name)
		try {
			$result = ([xml]$server.InvokeElem($request)).results
		}
		catch [NetApp.Manage.NaApiFailedException]{
			Write-Warning $_.Exception.GetBaseException().message
			$result = $null
			continue;
		}
		if ($?) {
			return $result.status[1]
		}
	}
}
